package com.joe.networkdisk.utils;

import com.joe.network.response.UserInfoDTO;
import com.joe.network.utils.JSONUtils;
import com.joe.network.utils.JWTUtils;
import io.jsonwebtoken.Claims;
import org.springframework.stereotype.Component;

/**
 * @author ckh
 * @since 2020/11/25 4:52 PM
 */
@Component
public class TokenAnalysisUtils {
    public UserInfoDTO tokenAnalysis(String token) {
        Claims claims = JWTUtils.parseJWT(token, "nimadetou".getBytes());
        String subject = claims.getSubject();
        return JSONUtils.parseObject(subject, UserInfoDTO.class);
    }
}
